/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package library.command;

import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author MonStar
 */
public class CommandsControl {

    private static CommandsControl instance;
    private List<ICommand> listCommand;

    public List<ICommand> getListCommand() {
        return listCommand;
    }

    private CommandsControl() {
        listCommand = new ArrayList<>();
        listCommand.add(new AddCommand());
        listCommand.add(new OutputCommand());
        listCommand.add(new RemoveCommand());
    }

    public synchronized static CommandsControl getInstance() {
        if (instance == null) {
            instance = new CommandsControl();
        }
        return instance;
    }

    public void execute(String... args) {
        for (String com : args) {
            for (ICommand command : listCommand) {
                if (command.name().equals(com)) {
                    command.execute(args);
                }
            }
        }
    }
}
